# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        Young  
# Name:         classtest
# Description:
# Author:       asus
# Date:         2019/3/6
#-------------------------------------------------------------------------------


zs_dict = {
    '1到99':[],
    '100到999':[],
    '1000到1999':[]
}
dict1 = []
#获取质数
def get_zhsh(a,b):
    leap = 1
    for i in range(a,b):
        k = (int(i / 2) + 1)
        for j in range(2, k):
            if (i % j == 0):
                leap = 0
                break
        if leap:
            print(i)
            dict1.append(i)
        leap = 1
print(dict1)

#按区间计算质数
def zhsh(zs_dict):
    for v in range(1,4):
        if v == 1:
            for i in dict1:
                if i<100:
                    zs_dict['1到99'].append(i)
        elif v == 2:
            for i in dict1:
                if i<1000 and i>100:
                    zs_dict['100到999'].append(i)
        else:
            for i in dict1:
                if i>1000 and i<2000:
                    zs_dict['1000到1999'].append(i)
            print(zs_dict)


if __name__ == '__main__':
    get_zhsh(1,2000)
    zhsh(zs_dict)
#
# #测试函数
# if __name__ == '__main__':
#     pass
#
#
# leap = 1
# for i in range(start,end):
#     k = (int(i/2)+1)
#     for j in range(2,k):
#         if(i%j == 0):
#             leap = 0
#             break
#     if leap:
#         print(i)
#         zhsh_dict = ['{}到{}'.format(start,end)].append(i)
#     leap = 1
# print(zhsh_dict)